package com.chinatechstar.component.commons.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PinyinUtils {

    // 检验是不是中文
    public static boolean isChinese(String str) {
        if (StrUtils.isNullOrEmpty(str)) {
            return false;
        }
        String regEx = "[\u4e00-\u9fa5]";
        Pattern pat = Pattern.compile(regEx);
        Matcher matcher = pat.matcher(str);
        boolean flg = false;
        if (matcher.find()) {
            flg = true;
        }

        return flg;
    }

    // 检验是不是英文
    public static boolean isEnglish(String str) {
        if (StrUtils.isNullOrEmpty(str)) {
            return false;
        }
        String regEx = "[A-Za-z]";
        Pattern pat = Pattern.compile(regEx);
        Matcher matcher = pat.matcher(str);
        boolean flg = false;
        if (matcher.find()) {
            flg = true;
        }

        return flg;
    }

    public static void main(String[] args) {
        boolean english = isChinese("");
        System.out.println(english);
    }
}
